home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 4 / The 640 Meg Shareware Studio CD-ROM Volume IV (Data Express)(1994).ISO / clang / 140_01.zip / STRIP.C < prev    next >
Text File  |  1993-06-26  |  1KB  |  69 lines

  1. /*
  2. Usage: STRIP <infile> <outfile>
  3.  
  4. This program strips the high order bit from each byte in <infile> and
  5. creates <outfile> from the stripped data.
  6.  
  7. Modifications:
  8.  
  9. 15/Jun/1982
  10. Originally from BDS "C" UG but took forever to run due to printing
  11. a running total of characters processed. Modified to print only a
  12. total character count at the end. Bill Bolton, Softwate Tools,
  13. Australia. 
  14.  
  15. */
  16.  
  17. #include bdscio.h
  18. #define INFILE 1
  19. #define OUTFILE 2
  20.  
  21. main(argc, argv)
  22.  
  23. int argc;
  24. char *argv[];
  25.  
  26. {
  27. int i;
  28. int input;
  29. char wrkbuf[BUFSIZ];
  30. char wrkbuf2[BUFSIZ];
  31.  
  32. i=0;
  33.  
  34.  
  35. if (argc!=3) {
  36.     prtuse();
  37.     return;
  38.     }
  39.  
  40. if (fopen(argv[INFILE],wrkbuf)==ERROR){
  41.     printf("\nCan't open %s",argv[INFILE]);
  42.     prtuse();
  43.     return;
  44.     }
  45. if (fcreat(argv[OUTFILE],wrkbuf2)==ERROR){
  46.     printf("\nCan't open %s",argv[OUTFILE]);
  47.     prtuse();
  48.     return;
  49.     }
  50. while(((input=getc(wrkbuf))>0)&&(putc((input & 0x7f), wrkbuf2)!=ERROR)){
  51.         ++i;
  52.     }
  53. printf("\n%d characters processed.\n",i);
  54. if (putc(CPMEOF,wrkbuf2)<0){ 
  55.     printf("\nCan't write end of file marker in %s",argv[INFILE]);
  56.     }
  57. if((fclose(wrkbuf)<0)) {
  58.     printf("\nCan't close %s",argv[INFILE]);
  59.     }
  60. if(((fflush(wrkbuf2)<0)||(fclose(wrkbuf2)<0))){
  61.     printf("\nCan't close %s",argv[OUTFILE]);
  62.     }
  63. }
  64.  
  65. prtuse()
  66. {
  67. printf("\nUSAGE: strip <infile> <outfile>");
  68. }
  69.